package utils;

import com.hfy.model.vo.MusicVo;
import result.Result;

import java.util.List;

/**
 * @ author 韩
 * time: 2024/7/1 7:17
 */

public class MusicConverter {
    public static Result getMusicResult(List<MusicVo> musicList) {
        for (MusicVo vo : musicList) {
            if (vo.getDuration() != null && !vo.getDuration().isEmpty()) {
                int temp = Integer.parseInt(vo.getDuration());
                int minutes = temp / 60;
                int seconds = temp % 60;
                // 使用String.format来格式化分钟和秒数，确保它们都是两位数
                vo.setDuration(String.format("%02d:%02d", minutes, seconds));
            }
        }
        return Result.ok(musicList);
    }
}
